package com.zts.modules.sys.mapper;

/**
 * Created by jisd on 2017/6/16.
 */

import com.zts.base.data.CrudMapper;
import com.zts.modules.sys.entity.Resource;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

public interface ResourceMapper extends CrudMapper<Resource> {
    @SelectProvider(type = ResourceSqlProvider.class, method = "get")
    Resource get(Long var1);

    @SelectProvider(type = ResourceSqlProvider.class, method = "getByEntity")
    List<Resource> getByEntity(Resource var1);

    @SelectProvider(type = ResourceSqlProvider.class, method = "getList")
    List<Resource> getList(Resource var1, RowBounds var2);

    @UpdateProvider(type = ResourceSqlProvider.class, method = "update")
    int update(Resource var1);

    @InsertProvider(type = ResourceSqlProvider.class, method = "insert")
    @SelectKey(statement = {"SELECT CURRVAL('seq_sys_resource_id')"}, keyProperty = "id", before = false, resultType = Long.class)
    int insert(Resource var1);

    @DeleteProvider(type = ResourceSqlProvider.class, method = "delete")
    int delete(Resource var1);

    @SelectProvider(type = ResourceSqlProvider.class, method = "getByRoles")
    List<Resource> getByRoles(@Param("roleIds") String roleIds, @Param("type") String type, @Param("resourceCode") String resourceCode);

    @InsertProvider(type = ResourceSqlProvider.class, method = "addRoleResource")
    @SelectKey(statement = {"SELECT CURRVAL('seq_sys_role_resource_id')"}, keyProperty = "id", before = false, resultType = Long.class)
    int addRoleResource(@Param("roleId") Long roleId, @Param("resourceIds") List<Long> resourceIds);

    @DeleteProvider(type = ResourceSqlProvider.class, method = "deleteRoleResource")
    int deleteRoleResource(@Param("roleId") Long roleId, @Param("resourceIds") List<Long> resourceIds);

}